﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using HuynhQuangWebsite.Models;
namespace HuynhQuangWebsite.Controllers
{
    [HandleError]
    public class Trang_chuController : Controller
    {
        huynhquangco_websiteEntities ctx = new huynhquangco_websiteEntities();
        public ActionResult Trang_chu()
        {
            var model = new HomeListViewModel();
            //list project is typical
            IList<Project> projectList = ctx.Projects.Where(p => p.ProjectIsTypical).OrderByDescending(p => p.ProjectStartDate).Take(5).ToList();
            model.ProjectList = projectList;
            //list video 
            IList<Video> videos = ctx.Videos.OrderBy(p => p.SortOrder).Take(5).ToList();
            model.VideoList = videos;
            //company strength
            IList<CompanyStrength> companyStrengths = ctx.CompanyStrengths.Where(p=>p.CompanyStrengthIsVisible).ToList();
            model.CompanyStrengthList = companyStrengths;
            //About us
            AboutU about = ctx.AboutUs.SingleOrDefault<AboutU>();
            model.AboutUs = about;
            //banner
            //IList<Banner> banners = ctx.Banners.Where(p => p.BannerIsVisible).OrderBy(p => p.BannerSortOrder).ToList();
            //model.BannerList = banners;
            return View(model);
        }
    }
}
